package com.lujianfei.redpacketstat.utils

import android.content.Context
import com.lujianfei.redpacketstat.App

object AppVersion {
    fun getAppName(context: Context = App.instance): String {
        return try {
            val packageInfo = context.packageManager.getPackageInfo(context.packageName, 0)
            context.resources.getString(packageInfo.applicationInfo.labelRes)
        } catch (e: Exception) {
            "Unknown"
        }
    }
    fun getVersionName(context: Context = App.instance): String {
        return try {
            val packageInfo = context.packageManager.getPackageInfo(context.packageName, 0)
            packageInfo.versionName
        } catch (e: Exception) {
            "Unknown"
        }
    }
}